package com.david.service;

import com.david.dao.AdminInfoDao;
import com.david.entity.AdminInfo;
import com.david.utils.WebAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class AdminInfoService {

    @Resource
    private AdminInfoDao adminInfoDao;

    /**
     * 登陆检查
     * @param info
     * @return
     */
    public AdminInfo checkLogin(AdminInfo info) {

        AdminInfo adminInfo = adminInfoDao.Login(info);

        return adminInfo;
    }

    /**
     * 获取全部
     * @return
     */
    public List<AdminInfo> findAll() {
        return adminInfoDao.findAll();
    }

    /**
     * 根据id获取
     * @param id
     * @return
     */
    public AdminInfo GetAdminById(Integer id) {
        AdminInfo info = adminInfoDao.GetAdminById(id);
        return info;
    }

    /**
     * 验证旧密码是否正确
     */
    public AdminInfo CheckOldPass(AdminInfo adminInfo){
        AdminInfo info = adminInfoDao.CheckOldPass(adminInfo);
        return info;
    }

    /**
     * 修改密码
     * @param adminInfo
     * @return
     */
    public int UpdatePassWord(AdminInfo adminInfo){
        return adminInfoDao.UpdatePassWord(adminInfo);
    }

}
